<?php
/**
 * Created by PhpStorm.
 * User: Aliaksei Lazerka
 * Date: 10/7/14
 * Time: 4:43 PM
 */

namespace controller;

if (!defined('NYMPH_ROOT')) {
  define('NYMPH_ROOT', dirname("../../../" . __FILE__));
  require(NYMPH_ROOT . '/local/loader/kernel/classes/URLClassLoader.php');
}

/**
 * Class Filter web filter
 * @package controller
 */
class Filter extends BaseWebActor
{
  /**
   * @var array action mappings array
   */
  private $actionMappings;

  /**
   * @var array action mappings exceptions array
   */
  private $actionMappingsException;

  /**
   * @var array with urls
   */
  private $urlMappings;

  public function addActionMapping($mappingName)
  {
    $this->actionMappings[] = $mappingName;
  }

  public function addActionMappingException($mappingName)
  {
    $this->actionMappingsException[] = $mappingName;
  }

  /**
   * @param string $mappingName name of the mapping
   * @return bool
   */
  public function checkMapping($mappingName)
  {
    return in_array($mappingName, $this->actionMappings);
  }

  /**
   * @param string $mappingName name of the mapping
   * @return bool
   */
  public function isMappingException($mappingName)
  {
    return in_array($mappingName, $this->actionMappingsException);
  }

  /**
   * @param string $mappingUrl
   * @return bool
   */
  public function checkUrlMapping($mappingUrl)
  {
    return in_array($mappingUrl, $this->urlMappings);
  }

} 